home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / s_to_z / startmup / startmup.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-15  |  2KB  |  108 lines

  1. unit StartMup;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, MMsystem, DsgnIntf, TypInfo;
  8.  
  9. type
  10.   TStartMeUpEditor = class(TComponentEditor)
  11.        function GetVerbCount: Integer; Override;
  12.        function GetVerb(index: Integer):String; Override;
  13.        procedure ExecuteVerb(index: Integer); Override;
  14.        procedure Execute;
  15.        procedure About;
  16.        procedure Help;
  17.   end;
  18.   TStartMeUp = class(TComponent)
  19.   public
  20.     procedure Execute;
  21.   end;
  22.  
  23. procedure Register;
  24.  
  25. implementation
  26.  
  27. {$R STARTMUP.RES }
  28.  
  29. procedure StartItUp;
  30. var
  31.   FindRes:THandle;
  32.   LoadRes:THandle;
  33.   LockPtr:PChar;
  34. begin
  35.   FindRes := FindResource(hInstance,'WAVSTARTMEUP','WAVE');
  36.   LoadRes := LoadResource(hInstance,FindRes);
  37.   LockPtr := PChar(LockResource(LoadRes));
  38.   sndPlaySound(LockPtr,SND_MEMORY+SND_SYNC);
  39.   UnlockResource(LoadRes);
  40.   FreeResource(LoadRes);
  41. end;
  42.  
  43. procedure TStartMeUp.Execute;
  44. begin
  45.   StartItUp;
  46. end;
  47.  
  48. function TStartMeUpEditor.GetVerbCount: integer;
  49. begin
  50.   result := 3;
  51. end;
  52.  
  53. function TStartMeUpEditor.GetVerb(index: Integer): string;
  54. begin
  55.   case index of
  56.     0:result := 'E&xecute';
  57.     1:result := '&Help..';
  58.     2:result := 'About..';
  59.   end;
  60. end;
  61.  
  62. procedure TStartMeUpEditor.ExecuteVerb(index:integer);
  63. begin
  64.   case index of
  65.     0:execute;
  66.     1:help;
  67.     2:about;
  68.   end;
  69. end;
  70.  
  71. procedure TStartMeUpEditor.Execute;
  72. begin
  73.   StartItUp;
  74. end;
  75.  
  76. procedure TStartMeUpEditor.About;
  77. const
  78.   cr = #13;
  79. begin
  80.   MessageDlg('"Start Me Up" Component'+cr+cr+
  81.              'Written by Pepijn Smits'+cr+
  82.              'CompuServe 74750,733'+cr+cr+
  83.              'This Component is Freeware'+cr+cr+
  84.              'See STARTMUP.TXT for more information'
  85.              ,mtInformation,[mbOk],0)
  86. end;
  87.  
  88. procedure TStartMeUpEditor.Help;
  89. const
  90.   cr = #13;
  91. begin
  92.   MessageDlg('Help for "Start Me Up" Component'+cr+cr+
  93.              'The component has only 1 method: Execute, '+
  94.              'that method will sound the first tunes of '+
  95.              '"Start Me Up". The sound is stored in a '+
  96.              'resource and thus included in the .EXE, so there''s no '+
  97.              'need for a separate .WAV file.'
  98.              ,mtInformation,[mbOk],0)
  99. end;
  100.  
  101. procedure Register;
  102. begin
  103.   RegisterComponents('Samples', [TStartMeUp]);
  104.   RegisterComponentEditor(TStartMeUp,TStartMeUpEditor);
  105. end;
  106.  
  107. end.
  108.